import {
  q as i,
  p as V,
  ap as z,
  X as p,
  f as D,
  H as M,
  av as g,
  aw as U,
  k as h,
  m,
  l as y,
  as as s,
  at as d
} from "./index-b50e6ef9.js";
import { a as q } from "./goods-bd9f9b53.js";
import { e as A, f as F } from "./square-934d8760.js";
function _(v) {
  const l = i([]),
    a = i(!0);
  i({}), V(), i(!1);
  const w = z("reload"),
    u = p({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    x = p({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    b = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "标签名称", prop: "name", minWidth: 200 },
      { label: "排序", prop: "order", minWidth: 200 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return h(
              y("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [m("启用")] }
            );
          if (e == 2)
            return h(
              y("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [m("禁用")] }
            );
        }
      },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    B = D(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function S(e) {
    const n = { id: e.id },
      c = JSON.stringify(n),
      t = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(c)) },
      o = await A(t);
    o.code == 200
      ? (d("删除成功", { type: "success" }), w())
      : d(o.msg, { type: "error" });
  }
  function C() {}
  function I(e) {}
  function L(e) {}
  function J(e) {}
  function k(e) {
    (x.text = `正在加载第${e}页...`),
      (a.value = !0),
      g(600).then(() => {
        a.value = !1;
      });
  }
  async function f(e, n) {
    a.value = !0;
    const r = JSON.stringify({ wares_id: e, wares_status: n }),
      o = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(r)) },
      { data: T } = await q(o);
    (l.value = T),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function W() {
    const n = JSON.stringify({ page: 1, pagesize: 20 }),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(n)) },
      t = await F(r);
    t.code === 200
      ? ((l.value = t.data),
        (u.total = t.data.length),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : d(t.msg, { type: "error" });
  }
  const N = e => {
    e && (e.resetFields(), f());
  };
  return (
    M(() => {
      g().then(() => {
        const { setWatermark: e } = U(v.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        W();
    }),
    {
      loading: a,
      columns: b,
      dataList: l,
      pagination: u,
      buttonClass: B,
      onSearch: f,
      resetForm: N,
      handleaddUser: C,
      handleDelete: S,
      handleSizeChange: I,
      handleCurrentChange: L,
      handleSelectionChange: J,
      onCurrentChange: k
    }
  );
}
export { _ as useRole };
